package com.huaxin.hxcloud.frendcircles;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bumptech.glide.Glide;
import com.huaxin.common.Entity.FindInfo;
import com.huaxin.common.message.view.CircleImageView;
import com.huaxin.common.view.avatarimageview.AvatarImageView;
import com.huaxin.common.view.avatarimageview.HxAvatarImageGlide;
import com.huaxin.hxcloud.R;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by hebing on 2017/5/8.
 */

public class IconRecyclerAdapter extends RecyclerView.Adapter<IconRecyclerAdapter.RecyclerHolder> {

    private Context context;
    protected List<FindInfo.LikeerArrayBean> datas = new ArrayList();

    public IconRecyclerAdapter(Context context) {
        this.context = context;
    }

    public List getDatas() {
        if (datas == null)
            datas = new ArrayList();
        return datas;
    }

    public void setDatas(List datas) {
        this.datas = datas;
    }

    @Override
    public IconRecyclerAdapter.RecyclerHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.item_top_info_3, parent, false);
        return new IconRecyclerAdapter.RecyclerHolder(inflate);
    }

    @Override
    public void onBindViewHolder(IconRecyclerAdapter.RecyclerHolder holder, int position) {
        FindInfo.LikeerArrayBean arrayBean = datas.get(position);

        HxAvatarImageGlide instance = HxAvatarImageGlide.getInstance();
        instance.setHeadImage(context, arrayBean.getImg(), arrayBean.getNickName(), holder.ci3);

        //  Glide.with(context).load(arrayBean.getImg()).error(R.color.bg_no_photo).into(holder.ci3);
    }

    @Override
    public int getItemCount() {
        return datas.size();
    }

    class RecyclerHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.find_ci3)
        AvatarImageView ci3;

        public RecyclerHolder(View view) {
            super(view);
            view.setTag(this);
            ButterKnife.bind(this, view);
        }
    }
}


